﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using System.Web.Security;

namespace SimpleScrum.Areas.Admin.Models
{
    public class AdminViewModel
    {
        public string TotalUserCount { get; set; }
        public string TotalUsersOnlineCount { get; set; }
        public string TotalRolesCount { get; set; }
    }

    public class ChangePasswordViewModel
    {
        [Required]
        [DataType(DataType.Password)]
        [Display(Name = "Current password")]
        public string OldPassword { get; set; }

        [Required]
        [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
        [DataType(DataType.Password)]
        [Display(Name = "New password")]
        public string NewPassword { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "Confirm new password")]
        [System.Web.Mvc.Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match."
            )]
        public string ConfirmPassword { get; set; }
    }

    public class ForgotPasswordViewModel
    {
        [Required(ErrorMessage = "Email is required.")]
        public string Email { get; set; }

        [Display(Name = "Secret Question")]
        public string SecretQuestion { get; set; }

        [Display(Name = "Secret Answer")]
        public string SecretAnswer { get; set; }

        /// <summary>
        ///     Indicates whether the RequiresQuestionAndAnswer was already
        ///     checked in the ForgotPassword (POST) action method.  If so,
        ///     we will skip over that checking "if" statement.
        /// </summary>
        public bool Checked { get; set; }

        public bool RequireSecretQuestionAndAnswer { get; set; }
    }

    public class GrantRolesToUserViewModel
    {
        public MembershipUser User { get; set; }
        public string UserName { get; set; }
        public SelectList AvailableRoles { get; set; }
        public SelectList GrantedRoles { get; set; }
    }

    public class JsonResponse
    {
        public bool Success { get; set; }
        public string Message { get; set; }
        public string CssClass { get; set; }
        public bool Approved { get; set; }
        public string ApprovedStatus { get; set; }
        public bool Locked { get; set; }
        public string LockedStatus { get; set; }
        public List<ResponseItem> Messages { get; set; }
        public bool Exists { get; set; }
    }

    public class MailerModel
    {
        public string Email { get; set; }
        public string Password { get; set; }
        public string FromEmail { get; set; }
        public string Subject { get; set; }
        public string ToEmail { get; set; }
    }

    public class ManageRolesViewModel
    {
        public SelectList Roles { get; set; }
        public string[] RoleList { get; set; }
    }

    public class ManageUsersViewModel
    {
        public MembershipUserCollection Users { get; set; }
        public IList<MembershipUser> PaginatedUserList { get; set; }
        public string FilterBy { get; set; }
        public string SearchTerm { get; set; }
        public int PageSize { get; set; }
    }

    public class RegisterViewModel
    {
        [Required]
        [DataType(DataType.EmailAddress)]
        [Display(Name = "Email address")]
        public string Email { get; set; }

        [Required]
        [StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
        [DataType(DataType.Password)]
        [Display(Name = "Password")]
        public string Password { get; set; }

        [DataType(DataType.Password)]
        [Display(Name = "Confirm password")]
        [System.Web.Mvc.Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
        public string ConfirmPassword { get; set; }

        [Display(Name = "Secret Question")]
        public string SecretQuestion { get; set; }

        [Display(Name = "Secret Answer")]
        public string SecretAnswer { get; set; }

        public bool Approve { get; set; }

        public bool RequireSecretQuestionAndAnswer { get; set; }
    }

    public class ResponseItem
    {
        public bool Success { get; set; }
        public string Message { get; set; }
        public string CssClass { get; set; }
    }

    public class RoleViewModel
    {
        [Required(ErrorMessage = "RoleName is required.")]
        public string RoleName { get; set; }

        public string Description { get; set; }
    }

    public class SelectObject
    {
        public string value { get; set; }
        public string caption { get; set; }
    }

    public class UserViewModel
    {
        public MembershipUser User { get; set; }
        public bool RequiresSecretQuestionAndAnswer { get; set; }
        public string[] Roles { get; set; }
    }

    public class RolesModel
    {
        public string Email { get; set; }
        public string[] Roles { get; set; }
    }
}